#include "Loader.h"
#include "Core/IOStream.hpp"

namespace MLoader
{
	std::unordered_map<std::string, std::function<Loader*(void)>> Loader::Factory;

    Model* Loader::LoadFile(const std::string& file_path)
    {
        Path filePath(file_path.c_str());
        if (!filePath.Exists() || !CanLoad(filePath)) return nullptr;
        
        Model* m = nullptr;
        try {

            IOStream stream(filePath.AbsolutePath());
            m = ReadStream(stream, filePath);

        } catch (const std::exception& err) {
            ML_LOG("Error: Loader file, %s", err.what());
        }
        
        return m;
    }

}
